package com.tutu.utils;

import java.io.File;
import java.io.FileInputStream;

/**
 * 文件上传工具类
 * Created by 涂奕恒 on 2022/1/11.
 */
public class FileUploadUtils {

    //读取文件到byte[]
    @SuppressWarnings("ResultOfMethodCallIgnored")
    public static byte[] getFileBytes(String file) {
        try {
            File f = new File(file);
            int length = (int) f.length();
            byte[] data = new byte[length];
            new FileInputStream(f).read(data);
            return data;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
